package licode.unisop.authcenter.exception;

import licode.unisop.types.AuthConst;
import licode.unisop.unilite.result.UniException;

/**
 * 定义SSO认证中心的错误码
 * SSO认证中心的错误码开头为901
 *
 * @author WR
 */
public enum CenterErrorCode {

    SUCCESS(0, "成功"),
    USER_DONT_EXIST(901000, "用户不存在"),
    LACK_OF_USER_ID(901001, "缺失用户标识"),
    LACK_OF_PLATFORM_ID(901002, "缺失平台标识"),
    WRONG_TARGET_USER(901003, "不能编辑用户自身"),
    WRONG_TARGET_CLIENT(901004, "当前客户标识不能删除"),
    NO_GRANT_EDIT_SYSTEM_USER(901005, "无权修改系统用户"),
    PLATFORM_DONT_SAME(901006, "平台标识不一致"),
    INVALID_PLATFORM(901007, "无效平台"),
    GRANT_FORBIDDEN(901008, "无此操作权限"),
    USER_NOT_LOGIN(AuthConst.USER_NOT_LOGIN, AuthConst.USER_NOT_LOGIN_MSG),
    PLATFORM_ID_IS_BLANK(901008, "平台标识不能为空"),
    REALM_ID_IS_BLANK(901009, "领域标识不能为空"),
    ASSET_IS_DONT_EXIST(901010, "资源不存在"),
    REALM_IS_DONT_EXIST(901011, "领域不存在"),
    PLATFORM_IS_DONT_EXIST(901012, "平台不存在"),
    PARAMS_IS_DONT_EXIST(901013, "参数错误：父资源标识不能为空"),
    ASSET_TYPE_BLANK(901014, "资源类型不能为空"),
    ASSET_REMOVE_SUB_ASSET(901015, "资源存在子资源，不能删除"),
    ASSET_DONT_DEL_DEFAULT_ASSET(901016, "默认资源，不能删除"),
    ASSET_WRONG_STATE(901017, "资源状态错误"),
    CANT_EDIT_DEFAULT_PLATFORM(901018, "系统平台，不能进行编辑！"),
    PLATFORM_DONT_BIND_REALM(901019, "平台未绑定任何领域！"),
    PLATFORM_ACCESS_TOKEN_EXPIRED(AuthConst.USER_NOT_LOGIN, "登录已失效！"),
    SYSTEM_BUSY(901999, "服务繁忙");

    private final Integer code;
    private final String message;

    CenterErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer code() {
        return this.code;
    }

    public String message() {
        return this.message;
    }

    public UniException buildException() {
        return new UniException(this.code, this.message);
    }
}
